package com.iyimo.manager
{
	import com.iyimo.util.IUtil;
	
	import flash.display.MovieClip;
	import flash.utils.Dictionary;

	public class SpriteManager{
		/**
		 * 需要下载swf的路径, name:value, url:value
		 */		
		public static var urlArray:Array = new Array();
		
		/**
		 * 保存的swf对象
		 */		
		private static var data:Dictionary = new Dictionary();
		
		/**
		 * 格式化xml,用来加载
		 */		
		public static function formatXml(xml:XML):void{
			var preUrl:String = xml.ui.@prependURLs;
			for each (var swf:XML in xml.ui.swf){
				var urlObj:Object = new Object();
				urlObj.name = String(swf.@name);
				urlObj.url = preUrl + swf.@url;
				urlArray.push(urlObj);
			}
		}
		
		/**
		 * 添加sprite
		 * @param key name
		 * @param value  MovieClip
		 */		
		public static function addSprite(key:String, value:MovieClip):void{
			data[key] = value;
			IUtil.stopMovieClip(value);
		}
		
		public static function getSprite(key:String):MovieClip{
			return data[key] as MovieClip;
		}
	}
}